﻿/*
 * 设计模式 - 建造者模式
 * 目的: 上家定规范,下家来执行
 */

WorkSetp work = new Elephent();
work.Close();


WorkSetp work2 = new Rabbit();
work2.Close();


public abstract class WorkSetp
{
    protected abstract void Setp_1();
    protected abstract void Setp_2();
    protected abstract void Setp_3();

    public void Close()
    {
        Setp_1();
        Setp_2();
        Setp_3();
    }
}

public class Elephent : WorkSetp
{
    protected override void Setp_1()
    {
        Console.WriteLine("把冰箱门打开");
    }

    protected override void Setp_2()
    {
        Console.WriteLine("把大象放进去");
    }

    protected override void Setp_3()
    {
        Console.WriteLine("把冰箱门关上");
    }
}

public class Rabbit : WorkSetp
{
    protected override void Setp_1()
    {
        Console.WriteLine("把冰箱门打开");
    }

    protected override void Setp_2()
    {
        Console.WriteLine("把兔子放进去");
    }

    protected override void Setp_3()
    {
        Console.WriteLine("把冰箱门关上");
    }
}